package com.estronger.shopmanage.fragment;

import com.estronger.shopmanage.fragment.install.BuildBaseFragment;
import com.estronger.shopmanage.fragment.install.BuildFragment1;
import com.estronger.shopmanage.fragment.install.BuildFragment2;
import com.estronger.shopmanage.fragment.install.BuildFragment3;
import com.estronger.shopmanage.fragment.install.BuildFragment4;
import com.estronger.shopmanage.fragment.install.BuildFragment6;
import com.estronger.shopmanage.fragment.measure.MeasureBaseFragment;
import com.estronger.shopmanage.fragment.measure.MeasureFragment1;
import com.estronger.shopmanage.fragment.measure.MeasureFragment2;
import com.estronger.shopmanage.fragment.measure.MeasureFragment3;
import com.estronger.shopmanage.fragment.measure.MeasureFragment5;
import com.estronger.shopmanage.fragment.orderQuery.OrderBaseFragment;
import com.estronger.shopmanage.fragment.orderQuery.OrderFragment1;
import com.estronger.shopmanage.fragment.orderQuery.OrderFragment2;
import com.estronger.shopmanage.fragment.orderQuery.OrderFragment3;
import com.estronger.shopmanage.fragment.orderQuery.OrderFragment4;
import com.estronger.shopmanage.fragment.orderQuery.OrderFragment5;
import com.estronger.shopmanage.fragment.orderQuery.OrderFragment6;
import com.estronger.shopmanage.fragment.send.SendBaseFragment;
import com.estronger.shopmanage.fragment.send.SendFragment1;
import com.estronger.shopmanage.fragment.send.SendFragment2;
import com.estronger.shopmanage.fragment.send.SendFragment3;
import com.estronger.shopmanage.fragment.send.SendFragment5;
import com.estronger.shopmanage.fragment.send.pg.DeliverPGBaseFragment;
import com.estronger.shopmanage.fragment.send.pg.DeliverPGFragment1;
import com.estronger.shopmanage.fragment.send.pg.DeliverPGFragment2;
import com.estronger.shopmanage.fragment.install.pg.InstallPGBaseFragment;
import com.estronger.shopmanage.fragment.install.pg.InstallPGFragment1;
import com.estronger.shopmanage.fragment.install.pg.InstallPGFragment2;
import com.estronger.shopmanage.fragment.measure.pg.MsPGBaseFragment;
import com.estronger.shopmanage.fragment.measure.pg.MsPGFragment1;
import com.estronger.shopmanage.fragment.measure.pg.MsPGFragment2;

import java.util.HashMap;
import java.util.Map;

public class FragmentFactory {

	private static Map<Integer, MeasureBaseFragment> mFragments = new HashMap<Integer, MeasureBaseFragment>();
	private static Map<Integer, SendBaseFragment> sendFragments = new HashMap<Integer, SendBaseFragment>();
	private static Map<Integer, BuildBaseFragment> buildFragments = new HashMap<Integer, BuildBaseFragment>();
	private static Map<Integer, DeliverPGBaseFragment> deliverpgFragments = new HashMap<Integer, DeliverPGBaseFragment>();
	private static Map<Integer, InstallPGBaseFragment> installpgFragments = new HashMap<Integer, InstallPGBaseFragment>();
	private static Map<Integer, MsPGBaseFragment> measureFragments = new HashMap<Integer, MsPGBaseFragment>();
	private static Map<Integer, OrderBaseFragment> orderFragments = new HashMap<Integer, OrderBaseFragment>();

	public static MeasureBaseFragment createFragment(int position) {
		MeasureBaseFragment fragment = null;
		fragment = mFragments.get(position);
		if (fragment == null) {
			if (position == 0) {
				fragment = new MeasureFragment1();
			} else if (position == 1) {
				fragment = new MeasureFragment2();
			} else if (position == 2) {
				fragment = new MeasureFragment3();
			} else if (position == 3) {
				// fragment = new Fragment4();
				fragment = new MeasureFragment5();
			}
			if (fragment != null) {
				mFragments.put(position, fragment);
			}
		}
		return fragment;
	}

	public static SendBaseFragment createSendFragment(int position) {
		SendBaseFragment fragment = null;
		fragment = sendFragments.get(position);
		if (fragment == null) {
			if (position == 0) {
				fragment = new SendFragment1();
			} else if (position == 1) {
				fragment = new SendFragment2();
			} else if (position == 2) {
				fragment = new SendFragment3();
			} else if (position == 3) {
				fragment = new SendFragment5();
			} /*
			 * else if (position == 4) { fragment = new SendFragment5(); }
			 */

			if (fragment != null) {
				sendFragments.put(position, fragment);
			}
		}
		return fragment;
	}

	public static BuildBaseFragment createBuildFragment(int position) {
		BuildBaseFragment fragment = null;
		fragment = buildFragments.get(position);
		if (fragment == null) {
			if (position == 0) {
				fragment = new BuildFragment1();
			} else if (position == 1) {
				fragment = new BuildFragment2();
			} else if (position == 2) {
				fragment = new BuildFragment3();
			} else if (position == 3) {
				fragment = new BuildFragment4();
			} else if (position == 4) {
				fragment = new BuildFragment6();
			} /*
			 * else if (position == 5) { fragment = new BuildFragment6(); }
			 */

			if (fragment != null) {
				buildFragments.put(position, fragment);
			}
		}
		return fragment;
	}
	public static MsPGBaseFragment createMeasurePGFragment(int position) {
		MsPGBaseFragment fragment = null;
		fragment = measureFragments.get(position);
		if (fragment == null) {
			if (position == 0) {
				fragment = new MsPGFragment1();
			} else if (position == 1) {
				fragment = new MsPGFragment2();
			}
			if (fragment != null) {
				measureFragments.put(position, fragment);
			}
		}
		return fragment;
	}
	
	public static DeliverPGBaseFragment createDeliverPGFragment(int position) {
		DeliverPGBaseFragment fragment = null;
		fragment = deliverpgFragments.get(position);
		if (fragment == null) {
			if (position == 0) {
				fragment = new DeliverPGFragment1();
			} else if (position == 1) {
				fragment = new DeliverPGFragment2();
			}

			if (fragment != null) {
				deliverpgFragments.put(position, fragment);
			}
		}
		return fragment;
	}

	public static InstallPGBaseFragment createInstallPGFragment(int position) {
		InstallPGBaseFragment fragment = null;
		fragment = installpgFragments.get(position);
		if (fragment == null) {
			if (position == 0) {
				fragment = new InstallPGFragment1();
			} else if (position == 1) {
				fragment = new InstallPGFragment2();
			}
			if (fragment != null) {
				installpgFragments.put(position, fragment);
			}
		}
		return fragment;
	}

	public static OrderBaseFragment createOrderFragement(int position){
		OrderBaseFragment fragment = null;
		fragment = orderFragments.get(position);
		if (fragment == null) {
			if (position == 0) {
				fragment = new OrderFragment1();
			} else if (position == 1) {
				fragment = new OrderFragment2();
			} else if(position == 2){
				fragment = new OrderFragment3();
			} else if(position == 3){
				fragment = new OrderFragment4();
			} else if(position == 4){
				fragment = new OrderFragment5();
			} else if(position == 5){
				fragment = new OrderFragment6();
			}
			if (fragment != null) {
				orderFragments.put(position, fragment);
			}
		}
		return fragment;
	}

	public static void clear() {mFragments.clear();}

	public static void clearSend() {
		sendFragments.clear();
	}

	public static void clearbuild() {
		buildFragments.clear();
	}

	public static void cleardeliverpg(){
		deliverpgFragments.clear();
	}

	public static void clearinstallpg(){
		installpgFragments.clear();
	}

	public static void clearpgMeasure(){measureFragments.clear();}

	public static void clearpgDeliver(){deliverpgFragments.clear();}

	public static void clearpgInstall(){installpgFragments.clear();}

	public static void clearOrderQuery(){orderFragments.clear();}
}
